<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>{$Think.lang.rle_man_page_title} - {$Think.lang.cfg_website}</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel='stylesheet' type='text/css' href='{$NOW_THEME_URL}/Assets/plugins/jquery-treetable/css/jquery.treeTable.css' />
	<script src="__PUBLIC__/Js/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/plugins/jquery-treetable/jquery.treetable.js"></script>
    <style type="text/css">
		#tree .odd {
			
		}
		
		#node-1 {
			background-color:#AAAAAA;
			color:#FFF;
		}
		
		.trlevel_1 {
			background-color:#EEEEEE;
		}
		.trlevel_2 {
			background-color:#F9F9F9;
		}
	</style>
</head>
<body>
	<form action="{:U('/User/menu')}" method="post" name="form" id="form">
		<input type="hidden" name="roleid" value="{$Think.get.roleid}" />
		<table id="tree" width="100%" border="0" cellpadding="4" cellspacing="1" class="table">
			{$html_tree}
		</table>
        <table width="100%" border="0" cellpadding="4" cellspacing="1" class="table" style="position:fixed; bottom:0px; left:0px; border-top:#CCC 1px solid; background-color:#AAAAAA;">
			<tr>
				<td>
                	<input type="button" id="openAll" value="{$Think.lang.rle_form_ele_allexpand}"/>
                    <input type="button" id="checkAll" value="{$Think.lang.rle_form_ele_allselect}"/>
					<input class="bginput" type="submit" name="dosubmit" value="{$Think.lang.cfg_form_ele_submit}" >
                    </td>
			</tr>
		</table>
	</form>
</body>
	<script type="text/javascript">
		$(document).ready(function() {
			//树配置
			$("#tree").treeTable({
				expandable: true,
			});
			
			
			var openStatus = false;
			var checkStatus = false;
			$('#openAll').on('click',function(){
				if(openStatus){
					$("#tree").collapseAll();
					openStatus = false;
				}else{
					$("#tree").expandAll();
					openStatus = true;
				}
			});
			
			$('#checkAll').on('click',function(){
				if(checkStatus){
					$(".mycheck").each(function(index, element) {
                       	//$(this).get(0).indeterminate=false;
						$(this).prop("checked", false);
                    });
					checkStatus = false;
				}else{
					$(".mycheck").each(function(index, element) {
                        //$(this).get(0).indeterminate=true;
						$(this).prop("checked", true);
                    });
					checkStatus = true;
				}
			});
		});
		
		function checknode(obj){
			  var chk = $("input[type='checkbox']");
			  var count = chk.length;
			  var num = chk.index(obj);
			  var level_top = level_bottom =  chk.eq(num).attr('level')
			  for (var i=num; i>=0; i--)
			  {
					  var le = chk.eq(i).attr('level');
					  if(eval(le) < eval(level_top)) 
					  {
						  chk.eq(i).attr("checked",'checked');
						  var level_top = level_top-1;
					  }
			  }
			  for (var j=num+1; j<count; j++)
			  {
					  var le = chk.eq(j).attr('level');
					  if(chk.eq(num).attr("checked")=='checked') {
						  if(eval(le) > eval(level_bottom)) chk.eq(j).attr("checked",'checked');
						  else if(eval(le) == eval(level_bottom)) break;
					  }
					  else {
						  if(eval(le) > eval(level_bottom)) chk.eq(j).attr("checked",false);
						  else if(eval(le) == eval(level_bottom)) break;
					  }
			  }
		  }
</script>
</html>